<template>
	<view class="content">
		<view class="bulding-info">
			<view class="title text-cut text-bold">
				{{options.housename}} 
				
				<text @tap="like" :data-isLike="false" :data-id="options.id" v-if="isLike" class="cuIcon-likefill text-red"></text>
				<text @tap="like" :data-isLike="true" :data-id="options.id" v-else class="cuIcon-like text-red"></text>
			</view>
			<view class="price text-bold"><text>{{options.houseprice}}元/㎡</text></view>
			<view class="company text-gray flex">开发商：{{options.companyname}}</view>
			<view class="addr text-blue flex" @tap="getLocation" ><text class="cuIcon-locationfill"></text>项目地址：{{options.houseaddress}}</view>
			<view class="publishDate text-gray flex">发布日期：{{options.createDateTime}}</view>
			<view class="other text-sm">
				<view class="text-green">
					<text>{{options.areaname}}</text>
					<text v-if="options.housetype!=null">{{options.housetype}}</text>
					<text v-if="options.fxmoney!=null&&options.fxmoney!=''" class="text-red">佣金:{{options.fxmoney}}</text>
				</view>
				
				
				
			</view>
		</view>
	</view>
</template>


<script>
	export default {
		data(){
		        return {
		            dataIsLike: this.isLike    //通过data, 定义新变量currentSearch, 这样currentSearch的值变更时，不会影响父组件传来的search的值
		        }
		    },
		props: {
			options: {
				type: Object,
				default: function(e) {
					return {}
				},
				
			},
			isLike: {
				type: Boolean,
				default: function(e) {
					return false
				},
				
			},
		},
		methods: {
			click() {
				this.$emit('click');
			},
			close(e) {
				this.$emit('close');
			},
			like(e){
				this.$parent.like();	
				// var me = this;
				// uni.getStorage({
				// 	key: 'UserInfo',
				// 	success: (res) => {
				// 		if (!res.data) {
				// 			return;
				// 		}
						
				// 		uni.request({
				// 			url: me.$rootUrl + '/Member/LikeHouse',
				// 			data: {
				// 				HouseId: e.currentTarget.dataset.id,
				// 				MemberId: res.data.id,
				// 				isLike:e.currentTarget.dataset.islike
				// 			},
				// 			method: 'Post',
				// 			success(res) {
				// 				if (res.data.success) {
				// 					me.dataIsLike=!me.dataIsLike;
				// 				} else {
				// 					uni.showModal({
				// 						content: '服务器错误!',
				// 						showCancel: false
				// 					});
				// 				}
				// 			},
				// 			fail() {
				// 				uni.showModal({
				// 					content: me.connectionFailText,
				// 					showCancel: false
				// 				});
				// 			}
				// 		});
						
						
				// 	},
				// 	fail: (e) => {
				// 		//this.toLogin(); 
				// 	}
				// });
			},
			
			
			getLocation(){
				var data=this.options;
				uni.getLocation({
				    type: 'gcj02', //返回可以用于uni.openLocation的经纬度
				    success: function (res) {
				        uni.openLocation({
				            latitude: data.lat,
				            longitude: data.lng,
							name:data.houseaddress,
				            success: function () {
				                console.log('success');
				            }
				        });
				    }
				});
				
			},
		}
	}
</script>

<style lang="scss">
	.content{
		display: flex;
		flex-direction: row;
		border-bottom: #E1D7F0 1px solid;
		background: #FFFFFF;
		padding:5px;
		.image{
			width:40vw;
			image{
				width:40vw;
				height: 30vw;
			}
		}
		.bulding-info{
			margin-left: 15px;
			display: flex;
			flex-direction: column;
			view{
				padding: 2px 0;
			}
			.title{
				font-size: 26px;
			}
			.price{
				color:#ED1C24
			}
			.other{
				display:flex;
				flex-direction: row;
				.text-green{
					flex:1;
					text{
						padding: 4px;
						margin-left:4px;
						background:#DDDDDD;
						
					}
				}
				.text-right{
					display: flex;
					flex-direction: row;
					width:30px;
					font-size: 12px;
				    .icon{
						font-size:13px;
					}
				}
			}
		}
	}
</style>
